/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-01-13 10:29:22
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-05-26 11:37:19
 * @FilePath: \cxl-h5\src\apis\wx\index.ts
 */
import { request as axios } from '@/axios/index'
import { Buffer } from 'buffer'
import { appId } from '@/utils/config'

/**
 * 获取wx-js-sdk 配置信息
 * @returns
 */
export const getdWeixinSdkConfig = () => {
    return axios({
        method: 'get',
        url: `/api/system/portal/wx/${appId}/getJsSDkConfig`,
        params: {
            signUrl: Buffer.from(encodeURI(window.location.href)).toString('base64')
        }
    })
}

/**
 * 通过code 获取用户信息
 * @param code
 * @returns
 */
export const getUserInfoByCode = (code: string) => {
    return axios({
        method: 'get',
        url: '/api/system/portal/wx/user',
        params: { code }
    })
}
